package com.binance.notification.web.service.abnormaltrade.enums;

import org.apache.commons.lang.StringUtils;

import com.binance.notification.web.utils.I18nUtils;

public enum AbnromalTradeNoticeDescEnum {
    // AbnormalPrice 相关文案
    AbnormalPrice_TO_THE_MOON("AbnormalPrice", "#{apc.tip1}", "To the MOON", "火箭发射", "3"),
    AbnormalPrice_BIG_PUMP("AbnormalPrice", "#{apc.tip2}", "Big Pump", "大幅拉升", "2"),
    AbnormalPrice_Pump("AbnormalPrice", "#{apc.tip3}", "Pump", "拉升", "1"),
    AbnormalPrice_Dump("AbnormalPrice", "#{apc.tip4}", "Dump", "跳水", "-1"),
    AbnormalPrice_BIG_Dump("AbnormalPrice", "#{apc.tip5}", "Big Dump", "猛烈打压", "-2"),
    AbnormalPrice_MEGA_Dump("AbnormalPrice", "#{apc.tip6}", "MEGA Dump", "大幅跳水", "-3"),
    // PriceBreakthroughs 价格突破相关文案
    PriceBreakthroughs_New_High_Daily("PriceBreakthroughs", "#{pb.tip1}", "New 24h High", "今日新高", "3"),
    PriceBreakthroughs_New_High_Weekly("PriceBreakthroughs", "#{pb.tip2}", "New 7-day High", "本周新高", "2"),
    PriceBreakthroughs_New_High_Monthly("PriceBreakthroughs", "#{pb.tip3}", "New 30-day High", "本月新高", "1"),
    PriceBreakthroughs_New_Low_Daily("PriceBreakthroughs", "#{pb.tip4}", "New 24h Low", "今日新低", "-1"),
    PriceBreakthroughs_New_Low_Weekly("PriceBreakthroughs", "#{pb.tip5}", "New 7-day Low", "本周新低", "-2"),
    PriceBreakthroughs_New_Low_Monthly("PriceBreakthroughs", "#{pb.tip6}", "New 30-day Low", "本月新低", "-3");

    AbnromalTradeNoticeDescEnum(String businessType, String descKey, String enDesc, String cnDesc, String descCode) {
        this.businessType = businessType;
        this.descKey = descKey;
        this.enDesc = StringUtils.defaultIfBlank(I18nUtils.getValue(descKey, "en"), enDesc);
        this.cnDesc = StringUtils.defaultIfBlank(I18nUtils.getValue(descKey, "cn"), cnDesc);
        this.descCode = descCode;
    }

    private String businessType;// 参考 AbnromalTradeBusinessTypeEnum
    private String descKey;// 极光推送中用来描述国际化文字的key
    private String enDesc;// 英文描述
    private String cnDesc;// 中文
    private String descCode;// 用来和前端交互的文案的代号，比方说我写-1就代表跳水，从需求文档中我们可以知道，涨和跌各有3种文案描述
    // 所以我们这样定义 "1" 代表涨的第一种文案，"2" 代表涨的第二种文案,"3" 代表涨的第三种文案
    // 所以我们这样定义 "-1" 代表跌的第一种文案，"-2" 代表跌的第二种文案,"-3" 代表跌的第三种文案

    public String getBusinessType() {
        return businessType;
    }

    public void setBusinessType(String businessType) {
        this.businessType = businessType;
    }

    public String getDescKey() {
        return descKey;
    }

    public void setDescKey(String descKey) {
        this.descKey = descKey;
    }

    public String getEnDesc() {
        return enDesc;
    }

    public void setEnDesc(String enDesc) {
        this.enDesc = enDesc;
    }

    public String getCnDesc() {
        return cnDesc;
    }

    public void setCnDesc(String cnDesc) {
        this.cnDesc = cnDesc;
    }

    public String getDescCode() {
        return descCode;
    }

    public void setDescCode(String descCode) {
        this.descCode = descCode;
    }


    public static AbnromalTradeNoticeDescEnum forDescCodeAndBusinessType(String descCode, String businessType) {
        for (AbnromalTradeNoticeDescEnum abnromalTradeNoticeDescEnum : AbnromalTradeNoticeDescEnum.values()) {
            Boolean descCodeFlag = abnromalTradeNoticeDescEnum.getDescCode().equals(descCode);
            Boolean businessTypeFlag = abnromalTradeNoticeDescEnum.getBusinessType().equals(businessType);
            if (descCodeFlag && businessTypeFlag) {
                return abnromalTradeNoticeDescEnum;
            }
        }
        return null;
    }
}
